<?php
declare (strict_types = 1);

namespace app\command;

use app\common\model\Article as articleModel;
use app\common\model\GzhTitle;
use app\opengzh\service\DeepSeekService;
use think\console\Command;
use think\console\Input;

use think\console\Output;

class Cmdarticle extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('Cmdarticle')
            ->setDescription('the Cmdarticle command');
    }

    protected function execute(Input $input, Output $output)
    {
    	// 指令输出 deepseek自动生成文章
        $titleModel = new GzhTitle();
        $list = $titleModel->where('is_article',1)->order('id','asc')->limit(15)->select()->toArray();
        if(sizeof($list)>0){
            $dsService = new DeepSeekService();
            foreach ($list as $v){
                $dsService->sendRequest($v);
            }
        }else{
            var_dump('没有可生成文章的标题');
        }

    	$output->writeln('Cmdarticle - over');
    }
}
